/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import type.PackingOrderStatus;

/**
 *
 * @author Andy
 */

@Entity(name = "PackingOrder")
public class PackingOrderEntity extends DataObjectEntity implements Serializable {
    
    private PackingOrderStatus status;    
    @OneToOne
    private ShippingOrderEntity shippingOrder;
    @OneToMany
    private Collection<ShippingRequestEntity> productToQuantity = new ArrayList<ShippingRequestEntity>();
    
    @ManyToOne
    private PackingListEntity packingList;

    public PackingOrderEntity() {
        super();
    }

    public ShippingOrderEntity getShippingOrder() {
        return shippingOrder;
    }

    public void setShippingOrder(ShippingOrderEntity shippingOrder) {
        this.shippingOrder = shippingOrder;
    }

    public PackingListEntity getPackingList() {
        return packingList;
    }

    public void setPackingList(PackingListEntity packingList) {
        this.packingList = packingList;
    }

    public PackingOrderStatus getStatus() {
        return status;
    }

    public void setStatus(PackingOrderStatus status) {
        this.status = status;
    }

    public Collection<ShippingRequestEntity> getProductToQuantity() {
        return productToQuantity;
    }

    public void setProductToQuantity(Collection<ShippingRequestEntity> productToQuantity) {
        this.productToQuantity = productToQuantity;
    }
    
    public double getTotalPrice(){
        double total = 0;
        for(ShippingRequestEntity request : productToQuantity){
            total += request.getTotalPrice();
        }
        return total;
    }

    @Override
    public String childToString() {
        return "PackingOrderEntity{" + "status=" + status + ", shippingOrder=" + shippingOrder + ", productToQuantity=" + productToQuantity + ", packingList=" + packingList + '}';
    }
    
}
